import http from "@/utils/request";

const apiPrefix = "/mainPage";


export async function addMainPage(data) {
    return await http.request({
        data: data,
        url: apiPrefix+'/add',
        method: 'post'
    })
}

export async function deleteMainPageById(id){
    return await http.request({
        params: {
            id
        },
        url: apiPrefix+'/id',
        method: 'delete'
    })
}

export async function deleteMainPageByIds(ids){
    return await http.request({
        params: {
            ids
        },
        url: apiPrefix+'/batch',
        method: 'delete'
    })
}


export async function searchMainPageById(id){
    return await http.request({
        params: {
            id
        },
        url: apiPrefix+'/id',
        method: 'get'
    })
}

export async function searchMainPage(params){
    return await http.request({
        params: params,
        url: apiPrefix,
        method: 'get'
    })
}

export async function searchMainPageLast(){
    return await http.request({
        url: apiPrefix+'/last',
        method: 'get'
    })
}


export async function updateMainPageById(data){
  return await http.request({
    data: data,
    url: apiPrefix,
    method: 'put'
  })
}


export async function searchRecommendLast(){
  return await http.request({
    url: '/goods/recommend',
    method: 'get'
  })
}

export async function addRecommendById(id){
  return await http.request({
    url: '/goods/recommend/add',
    method: 'post',
    data:{
      id
    }
  })
}

export async function updateRecommendByIds(ids){
  return await http.request({
    data: {
      ids
    },
    url: '/goods/recommend',
    method: 'post'
  })
}
